package com.wangjin.javaProject.service;


import com.alibaba.fastjson.JSONObject;
import com.wangjin.javaProject.Constants;
import com.wangjin.javaProject.bean.HotVideo;
import com.wangjin.javaProject.bean.HotVideoCommon;
import com.wangjin.javaProject.request.HttpUtils;

import java.util.List;

/**
 * @Creator: WangJin
 * @desc:   该方法用于获取热门数据, 并将热门数据返回
 * @Creation Data: 2021/12/24 15:24
 **/
public class HotVideoService {
    /**
     * 该方法用于获取热门数据, 并将热门数据返回
     * */
    public List<HotVideo> getHotVideo () {
        String url = Constants.TRIP_URL + "?key="
                + Constants.TRIP_KEY
                + "&type=hot_video"
                + "&size=20";
        String result = HttpUtils.get(url);

        //json 解析
        HotVideoCommon videoCommon = JSONObject.parseObject(result, HotVideoCommon.class);
        return videoCommon.result;
    }
}
